#ifndef BASICMEMBERSHIPFUNCTION_H
#define BASICMEMBERSHIPFUNCTION_H

#include <QPainter>
#include <QPointF>
#include <QDebug>

class BasicMembershipFunction
{
public:

    virtual ~BasicMembershipFunction();

    /* J Q: Does the copy operator also have to be non-virtual?
     *
     * A A: I actually don't know.  I haven't ever gone that deep into the
     * whole operator overloading side of things.
     */
    void operator = (const BasicMembershipFunction& src);

    /* All inline getters */
    inline QString  getName()       const { return m_name; }
    inline double   getFuzzyValue() const { return m_fuzzy_value; }
    inline QPointF* getPoints()     const { return m_points; }
    inline int      getSize()       const { return m_size; }
    inline QString  getType()       const { return m_type; }

    /* Parameter getters. Maybe unnecessary, since there is already a getter
     * for the whole array.
     */
    double getPoint(const int& whichPoint) const;

    /* Non const getter:  I don't think any getters should be non-const */
    double getCrispValue();

    /* All inline setters */
    inline void setCrispValue(const double& newVal) { m_fuzzy_value = newVal; }
    inline void setName(const QString& name)        { m_name = name; }
    inline void setOutput(bool b)                   { m_is_output = b; }

    /* All setters requiring an assertion */
    void setFuzzyValue(const double& probabilityLevel);
    void setPoint(const int& whichPoint, const double& newlocation);

    /* this may not be applicable for all shapes.*/
    void shiftShape(const double& amount);

    /* There are two more functions in my triangle class, might be redundant */

    virtual void calculateCentroid() = 0;
    virtual void calculateProbability(const double& crispInput) = 0;

protected:

    /** Constructor with a default size to allow the user to more efficiently
     * create BasicMF objects.  Membership fuctions should not be capable of
     * being instantiated without a type, so that functionality was moved to
     * the constructor.
     */
    BasicMembershipFunction(const QString &type, const int &size);

    /** Copy constructor */
    BasicMembershipFunction(const BasicMembershipFunction& src);

    QString m_type;
    QString m_name;

    int m_size;
    QPointF* m_points;

    double m_crisp_value;
    double m_fuzzy_value;

    bool m_is_output;

    inline void setType(const QString& type) { m_type = type; }
};

QDebug operator<<(QDebug dbg, const BasicMembershipFunction &funct);

#endif // BASICMEMBERSHIPFUNCTION_H
